Q: Is there a way for an application to query a codec and find out what non-RGB pixel formats it supports?
A: Codecs supporting non-RGB pixel formats should have a 'cpix' resource included in their public resource list containing the four character codes of their supported non-RGB pixel formats. This information can be retrieved by applications using GetComponentPublicResource .
Listing 1 demonstrates how an application can check to see if a specific non-RGB pixel format is supported by a codec.
Listing 1.
| Boolean DoesCodecSupportPixelFormat(Component inComponent,
OSType inFormat)
{
Boolean isSupported = false;
OSTypePtr *hResource = NULL;
long thePixelFormatCount;
int i;
OSErr err;
// NOTE: GetComponentPublicResource returns a Handle,
// not a resource - the caller should dispose this using
// DisposeHandle
err = GetComponentPublicResource(inComponent,
'cpix', 1,
(Handle*)&hResource);
if (err || (NULL == hResource)) goto bail;
thePixelFormatCount = GetHandleSize((Handle)hResource)/4);
for (i = 0; i < thePixelFormatCount && !isSupported; i++)
isSupported = ((*hResource)[i] == inFormat);
DisposeHandle((Handle)hResource);
bail:
return isSupported;
}
|
Codec developers:
A codec advertising support for '2vuy' , 'r408' and 'v408' would for example, include a 'cpix' resource as part of their public resource list which looks like Figure 1.
Figure 1.
| resource 'cpix' (kMyCPIXResID) {
{
'2vuy','r408','v408'
}
};
|
Back to top
References:
[Jan 05, 2004]
|